package com.doucat.support.component.tab;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import java.util.List;

/**
 * -----------------------------------------------------------------
 * Copyright (C) 2021-2031, by tonly, All rights reserved.
 * -----------------------------------------------------------------
 * File: VpAdapter.java
 * Author: wangfy
 * Create: 2021/6/23 10:28
 */
public class VpAdapter extends FragmentStateAdapter {
    private List<? extends Fragment> fragments;
    public VpAdapter(FragmentActivity fragmentActivity, List<? extends Fragment> fragments) {
        super(fragmentActivity);
        this.fragments=fragments;
    }

    @Override
    public Fragment createFragment(int position) {
        return fragments.get(position);
    }

    @Override
    public int getItemCount() {
        return fragments.size();
    }
}